$(function() {

    // ================alert 移除 折叠 全屏 开始====================
    + function(n) {
        "use strict";

        function u(i) {
            return this.each(function() {
                var r = n(this),
                    u = r.data("bs.alert");
                u || r.data("bs.alert", u = new t(this));
                "string" == typeof i && u[i].call(r)
            })
        }

        var i = '[data-dismiss="alert"]',
            t = function(t) {
                n(t).on("click", i, this.close)
            },
            r;
        t.VERSION = "3.3.1";
        t.TRANSITION_DURATION = 150;
        t.prototype.close = function(i) {
            function e() {
                r.detach().trigger("closed.bs.alert").remove()
            }

            var f = n(this),
                u = f.attr("data-target"),
                r;
            u || (u = f.attr("href"),
                u = u && u.replace(/.*(?=#[^\s]*$)/, ""));
            r = n(u);
            i && i.preventDefault();
            r.length || (r = f.closest(".alert"));
            r.trigger(i = n.Event("close.bs.alert"));
            i.isDefaultPrevented() || (r.removeClass("in"),
                n.support.transition && r.hasClass("fade") ? r.one("bsTransitionEnd", e).emulateTransitionEnd(t.TRANSITION_DURATION) : e())
        };
        r = n.fn.alert;
        n.fn.alert = u;
        n.fn.alert.Constructor = t;
        n.fn.alert.noConflict = function() {
            return n.fn.alert = r,
                this
        };
        n(document).on("click.bs.alert.data-api", i, t.prototype.close)
    }(jQuery);
    // ================alert 移除 折叠 全屏 结束====================

    // ================== Widgets面板 开始=========================
    (function InitiateWidgets() {
        $('.widget-header *[data-toggle="maximize"]').on("click", function(n) {
            n.preventDefault();
            var t = $(this).parents(".widget").eq(0),
                i = $(this).find("i").eq(0),
                r = "fa-compress",
                u = "fa-expand";
            t.hasClass("maximized") ? (i && i.addClass(u).removeClass(r),
                t.removeClass("maximized"),
                t.find(".widget-body").css("height", "auto")) : (i && i.addClass(r).removeClass(u),
                t.addClass("maximized"),
                maximize(t))
        });
        $('.widget-header *[data-toggle="collapse"]').on("click", function(n) {
            n.preventDefault();
            var t = $(this).parents(".widget").eq(0),
                r = t.find(".widget-body"),
                i = $(this).find("i"),
                u = "fa-angle-down",
                f = "fa-angle-up",
                e = 300;
            t.hasClass("collapsed") ? (i && i.addClass(f).removeClass(u),
                t.removeClass("collapsed"),
                r.slideUp(0, function() {
                    r.slideDown(e)
                })) : (i && i.addClass(u).removeClass(f),
                r.slideUp(200, function() {
                    t.addClass("collapsed")
                }))
        });
        $('.widget-header *[data-toggle="dispose"]').on("click", function(n) {
            n.preventDefault();
            var i = $(this),
                t = i.parents(".widget").eq(0);
            t.hide(300, function() {
                t.remove()
            })
        })
    })();
    // ================== Widgets面板 结束=========================


    //=====================列表页搜索=====================
    $(".search-more").click(function() {
        var h = $(".search-container").height();
        if (h <= 35) {
            $(".search-container").animate({ height: "100%", speed: 1500 });

            $(".search-more i").removeClass('fa-angle-down').addClass('fa-angle-up');


        } else {
            $(".search-container").animate({ height: "45px", speed: 1500 });
            $(".search-more i").removeClass('fa-angle-up').addClass('fa-angle-down');
        }
    });


    //================form右边连线 右侧收缩变化 左侧高度调整===============
    $(".form-wrap .form-right").resize(function() {
        var rightWrap = $(".form-right").height();
        var rightWrapLastChild = $(".form-right .widget:last-child").height();
        $(".line,.left-wrap").css({
            height: rightWrap - rightWrapLastChild - 36 + "px"
        });
    });
    $(".form-wrap .form-right").trigger('resize');

    //========================面板收缩切换================================
    $(".toggleWidget").click(function() {
        var hasClass = $($(".widget")[0]).hasClass('collapsed');
        if (hasClass) {
            //最终要去掉
            $(".widget").each(function() {
                var that = this;
                if ($(that).hasClass('collapsed')) {

                    $(that).find('.widget-body').slideDown(200, function() {
                        $(that).removeClass("collapsed")
                    });
                }
            });
        } else {
            //最终要加掉
            $(".widget").each(function() {
                var that = this;
                if (!$(that).hasClass('collapsed')) {
                    $(that).find('.widget-body').slideUp(200, function() {
                        $(that).addClass("collapsed")
                    });
                }
            });
        }
    });


});